﻿// CCheckCasePropertyGridCtrl.cpp: 实现文件
//

#include "stdafx.h"
#include "zChecker.h"
#include "CheckCasePropertyGridCtrl.h"


// CCheckCasePropertyGridCtrl

IMPLEMENT_DYNAMIC(CCheckCasePropertyGridCtrl, CMFCPropertyGridCtrl)

CCheckCasePropertyGridCtrl::CCheckCasePropertyGridCtrl()
{
	m_pCase = NULL;
}

CCheckCasePropertyGridCtrl::~CCheckCasePropertyGridCtrl()
{
	if (m_pCase != NULL)
	{
		m_pCase->Release();
		m_pCase = NULL;
	}
}


BEGIN_MESSAGE_MAP(CCheckCasePropertyGridCtrl, CMFCPropertyGridCtrl)
END_MESSAGE_MAP()



// CCheckCasePropertyGridCtrl 消息处理程序

void CCheckCasePropertyGridCtrl::Populate(ck::CheckCase* pCase)
{
	if (m_pCase != NULL)
	{
		m_pCase->Release();
		m_pCase = NULL;
	}

	this->RemoveAll();
	m_pCase = pCase;
	if (m_pCase)
	{
		m_pCase->AddRef();

		CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(_T("方案信息"));

		z_uint32 id = pCase->GetID();
		z_uint32 code = pCase->GetCode();
		const char* szCode = pCase->GetSCode();
		const char* szName = pCase->GetName();
		z_uint32 modelCode = pCase->GetModeCode();
		const char* szDescription = pCase->GetDescription();

		ck::CheckModel* pModel = NULL;
		ck::CheckModelManager* pModelManager = ck::CheckModelManager::GetInstance();
		pModel = pModelManager->GetModel(modelCode);

		pGroup->AddSubItem(new CMFCPropertyGridProperty("方案名称", (_variant_t)szName, _T("")));
		pGroup->AddSubItem(new CMFCPropertyGridProperty("方案编码", (_variant_t)szCode, _T("")));
		pGroup->AddSubItem(new CMFCPropertyGridProperty("方案说明", (_variant_t)szDescription, _T("")));
		pGroup->AddSubItem(new CMFCPropertyGridProperty("模型名称", (_variant_t)pModel->GetName(), _T("")));


		this->AddProperty(pGroup);
	}
}
